
import drawcanvas from "./drawcanvas";
import {get_equipment} from "@/js/api/index";
class equipmentMrg {
    constructor (param) {
        this.rack = param.rack
        this.parent = param.parent
        this.node = param.node;
        this.init()
    }
    async init () {
        let index = 0;

        let vbdata = await get_equipment(this.node.id, 1)

        let vfdata = await get_equipment(this.node.id, 0)

        console.log("前面板端口:", vbdata, vfdata)

        this.rack.node.traverse((child) => {
        if (child.isMesh) {
            console.log("------------:",  child, index)
            //if(child.name == 'Brocade 5300_1')applyLabeledTexturesToMesh(child as THREE.Mesh, ['A', 'B', 'C', 'D', 'E', 'F'], this.node, vdata);
            if(index == 2) {
                console.log("this.mesh.material.map.image1:", child.material.map.image)
                new drawcanvas({
                    mesh:child,
                    node:this.node,
                    dcanvas:child,
                    parent: this.parent,
                    data:vbdata
                })
            }
            if(index == 1) {
                
                console.log("this.mesh.material.map.image2:", child.material.map.image)
                new drawcanvas({
                    mesh:child,
                    node:this.node,
                    dcanvas:child,
                    parent: this.parent,
                    data:vfdata
                })
                    
            }
            index++
        }

    
    });
    }
}

export default equipmentMrg